package com.rc.saas.tenant.job;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Author: yang
 * @Date: 2022/5/9 22:09
 */
public class LiunxMysqlBackup {


    public void aa (){

    }

    public static void main(String[] args) throws IOException {
        Process process =null;
//文件夹路径
        String[] cmd = new String[] { "/bin/sh", "-c", "docker exec -it mysql mysqldump -h 172.18.118.35 -uroot -p123456 rc_2022 > /var/backup_20220510.sql  " };
        try {
            //执行命令
            process = Runtime.getRuntime().exec(cmd);
            System.out.println("备份");
            InputStreamReader ips = new InputStreamReader(process.getInputStream());
            BufferedReader br = new BufferedReader(ips);
            String line;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
